﻿/**  版本信息模板在安装目录下，可自行修改。
* EMPLOYEE.cs
*
* 功 能： N/A
* 类 名： EMPLOYEE
*
* Ver    变更日期             负责人  变更内容
* ───────────────────────────────────
* V0.01  2013/10/14 11:19:16   N/A    初版
*
* Copyright (c) 2012 TKFA Corporation. All rights reserved.
*┌──────────────────────────────────┐
*│　此技术信息为本公司机密信息，未经本公司书面同意禁止向第三方披露．　│
*│　版权所有：TKFA　　　　　　　　　　　　　　│
*└──────────────────────────────────┘
*/
using System;
using System.Data;
using System.Text;
using System.Data.OracleClient;
using TKFA.IDAL;
using Maticsoft.DBUtility;//Please add references
namespace TKFA.OracleDAL
{
	/// <summary>
	/// 数据访问类:EMPLOYEE
	/// </summary>
	public partial class EMPLOYEE:IEMPLOYEE
	{
		public EMPLOYEE()
		{}
		#region  BasicMethod



		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(TKFA.Model.EMPLOYEE model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into EMPLOYEE(");
			strSql.Append("USERID,SNUMBER,NAME,PARENT,SLEVEL,ISDETAIL,EMPGROUP,SDEPARTMENTCODE,GENDER,BIRTHDAY,DEGREE,PHONE,CARDID,DUTY,HIREDATE,LEAVEDATE,BANKACCOUNT,ADDRESS,EMAIL,NOTE,ISCREDITMANAGE,CREDITPERIOD,CREDITLEVEL,PROFESSIONALGROUP,UUID,BARCODES,FOTHERARACCTID,FOTHERAPACCTID,FPREAPACCTID,FPREARACCTID)");
			strSql.Append(" values (");
			strSql.Append(":USERID,:SNUMBER,:NAME,:PARENT,:SLEVEL,:ISDETAIL,:EMPGROUP,:SDEPARTMENTCODE,:GENDER,:BIRTHDAY,:DEGREE,:PHONE,:CARDID,:DUTY,:HIREDATE,:LEAVEDATE,:BANKACCOUNT,:ADDRESS,:EMAIL,:NOTE,:ISCREDITMANAGE,:CREDITPERIOD,:CREDITLEVEL,:PROFESSIONALGROUP,:UUID,:BARCODES,:FOTHERARACCTID,:FOTHERAPACCTID,:FPREAPACCTID,:FPREARACCTID)");
			OracleParameter[] parameters = {
					new OracleParameter(":USERID", OracleType.VarChar,20),
					new OracleParameter(":SNUMBER", OracleType.VarChar,20),
					new OracleParameter(":NAME", OracleType.VarChar,20),
					new OracleParameter(":PARENT", OracleType.VarChar,20),
					new OracleParameter(":SLEVEL", OracleType.VarChar,20),
					new OracleParameter(":ISDETAIL", OracleType.VarChar,20),
					new OracleParameter(":EMPGROUP", OracleType.VarChar,20),
					new OracleParameter(":SDEPARTMENTCODE", OracleType.VarChar,20),
					new OracleParameter(":GENDER", OracleType.VarChar,20),
					new OracleParameter(":BIRTHDAY", OracleType.DateTime),
					new OracleParameter(":DEGREE", OracleType.VarChar,20),
					new OracleParameter(":PHONE", OracleType.VarChar,20),
					new OracleParameter(":CARDID", OracleType.VarChar,20),
					new OracleParameter(":DUTY", OracleType.VarChar,20),
					new OracleParameter(":HIREDATE", OracleType.VarChar,20),
					new OracleParameter(":LEAVEDATE", OracleType.VarChar,20),
					new OracleParameter(":BANKACCOUNT", OracleType.VarChar,20),
					new OracleParameter(":ADDRESS", OracleType.VarChar,20),
					new OracleParameter(":EMAIL", OracleType.VarChar,20),
					new OracleParameter(":NOTE", OracleType.VarChar,20),
					new OracleParameter(":ISCREDITMANAGE", OracleType.VarChar,20),
					new OracleParameter(":CREDITPERIOD", OracleType.VarChar,20),
					new OracleParameter(":CREDITLEVEL", OracleType.VarChar,20),
					new OracleParameter(":PROFESSIONALGROUP", OracleType.VarChar,20),
					new OracleParameter(":UUID", OracleType.VarChar,20),
					new OracleParameter(":BARCODES", OracleType.VarChar,20),
					new OracleParameter(":FOTHERARACCTID", OracleType.VarChar,20),
					new OracleParameter(":FOTHERAPACCTID", OracleType.VarChar,20),
					new OracleParameter(":FPREAPACCTID", OracleType.VarChar,20),
					new OracleParameter(":FPREARACCTID", OracleType.VarChar,20)};
			parameters[0].Value = model.USERID;
			parameters[1].Value = model.SNUMBER;
			parameters[2].Value = model.NAME;
			parameters[3].Value = model.PARENT;
			parameters[4].Value = model.SLEVEL;
			parameters[5].Value = model.ISDETAIL;
			parameters[6].Value = model.EMPGROUP;
			parameters[7].Value = model.SDEPARTMENTCODE;
			parameters[8].Value = model.GENDER;
			parameters[9].Value = model.BIRTHDAY;
			parameters[10].Value = model.DEGREE;
			parameters[11].Value = model.PHONE;
			parameters[12].Value = model.CARDID;
			parameters[13].Value = model.DUTY;
			parameters[14].Value = model.HIREDATE;
			parameters[15].Value = model.LEAVEDATE;
			parameters[16].Value = model.BANKACCOUNT;
			parameters[17].Value = model.ADDRESS;
			parameters[18].Value = model.EMAIL;
			parameters[19].Value = model.NOTE;
			parameters[20].Value = model.ISCREDITMANAGE;
			parameters[21].Value = model.CREDITPERIOD;
			parameters[22].Value = model.CREDITLEVEL;
			parameters[23].Value = model.PROFESSIONALGROUP;
			parameters[24].Value = model.UUID;
			parameters[25].Value = model.BARCODES;
			parameters[26].Value = model.FOTHERARACCTID;
			parameters[27].Value = model.FOTHERAPACCTID;
			parameters[28].Value = model.FPREAPACCTID;
			parameters[29].Value = model.FPREARACCTID;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(TKFA.Model.EMPLOYEE model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update EMPLOYEE set ");
			strSql.Append("USERID=:USERID,");
			strSql.Append("SNUMBER=:SNUMBER,");
			strSql.Append("NAME=:NAME,");
			strSql.Append("PARENT=:PARENT,");
			strSql.Append("SLEVEL=:SLEVEL,");
			strSql.Append("ISDETAIL=:ISDETAIL,");
			strSql.Append("EMPGROUP=:EMPGROUP,");
			strSql.Append("SDEPARTMENTCODE=:SDEPARTMENTCODE,");
			strSql.Append("GENDER=:GENDER,");
			strSql.Append("BIRTHDAY=:BIRTHDAY,");
			strSql.Append("DEGREE=:DEGREE,");
			strSql.Append("PHONE=:PHONE,");
			strSql.Append("CARDID=:CARDID,");
			strSql.Append("DUTY=:DUTY,");
			strSql.Append("HIREDATE=:HIREDATE,");
			strSql.Append("LEAVEDATE=:LEAVEDATE,");
			strSql.Append("BANKACCOUNT=:BANKACCOUNT,");
			strSql.Append("ADDRESS=:ADDRESS,");
			strSql.Append("EMAIL=:EMAIL,");
			strSql.Append("NOTE=:NOTE,");
			strSql.Append("ISCREDITMANAGE=:ISCREDITMANAGE,");
			strSql.Append("CREDITPERIOD=:CREDITPERIOD,");
			strSql.Append("CREDITLEVEL=:CREDITLEVEL,");
			strSql.Append("PROFESSIONALGROUP=:PROFESSIONALGROUP,");
			strSql.Append("UUID=:UUID,");
			strSql.Append("BARCODES=:BARCODES,");
			strSql.Append("FOTHERARACCTID=:FOTHERARACCTID,");
			strSql.Append("FOTHERAPACCTID=:FOTHERAPACCTID,");
			strSql.Append("FPREAPACCTID=:FPREAPACCTID,");
			strSql.Append("FPREARACCTID=:FPREARACCTID");
			strSql.Append(" where ");
			OracleParameter[] parameters = {
					new OracleParameter(":USERID", OracleType.VarChar,20),
					new OracleParameter(":SNUMBER", OracleType.VarChar,20),
					new OracleParameter(":NAME", OracleType.VarChar,20),
					new OracleParameter(":PARENT", OracleType.VarChar,20),
					new OracleParameter(":SLEVEL", OracleType.VarChar,20),
					new OracleParameter(":ISDETAIL", OracleType.VarChar,20),
					new OracleParameter(":EMPGROUP", OracleType.VarChar,20),
					new OracleParameter(":SDEPARTMENTCODE", OracleType.VarChar,20),
					new OracleParameter(":GENDER", OracleType.VarChar,20),
					new OracleParameter(":BIRTHDAY", OracleType.DateTime),
					new OracleParameter(":DEGREE", OracleType.VarChar,20),
					new OracleParameter(":PHONE", OracleType.VarChar,20),
					new OracleParameter(":CARDID", OracleType.VarChar,20),
					new OracleParameter(":DUTY", OracleType.VarChar,20),
					new OracleParameter(":HIREDATE", OracleType.VarChar,20),
					new OracleParameter(":LEAVEDATE", OracleType.VarChar,20),
					new OracleParameter(":BANKACCOUNT", OracleType.VarChar,20),
					new OracleParameter(":ADDRESS", OracleType.VarChar,20),
					new OracleParameter(":EMAIL", OracleType.VarChar,20),
					new OracleParameter(":NOTE", OracleType.VarChar,20),
					new OracleParameter(":ISCREDITMANAGE", OracleType.VarChar,20),
					new OracleParameter(":CREDITPERIOD", OracleType.VarChar,20),
					new OracleParameter(":CREDITLEVEL", OracleType.VarChar,20),
					new OracleParameter(":PROFESSIONALGROUP", OracleType.VarChar,20),
					new OracleParameter(":UUID", OracleType.VarChar,20),
					new OracleParameter(":BARCODES", OracleType.VarChar,20),
					new OracleParameter(":FOTHERARACCTID", OracleType.VarChar,20),
					new OracleParameter(":FOTHERAPACCTID", OracleType.VarChar,20),
					new OracleParameter(":FPREAPACCTID", OracleType.VarChar,20),
					new OracleParameter(":FPREARACCTID", OracleType.VarChar,20)};
			parameters[0].Value = model.USERID;
			parameters[1].Value = model.SNUMBER;
			parameters[2].Value = model.NAME;
			parameters[3].Value = model.PARENT;
			parameters[4].Value = model.SLEVEL;
			parameters[5].Value = model.ISDETAIL;
			parameters[6].Value = model.EMPGROUP;
			parameters[7].Value = model.SDEPARTMENTCODE;
			parameters[8].Value = model.GENDER;
			parameters[9].Value = model.BIRTHDAY;
			parameters[10].Value = model.DEGREE;
			parameters[11].Value = model.PHONE;
			parameters[12].Value = model.CARDID;
			parameters[13].Value = model.DUTY;
			parameters[14].Value = model.HIREDATE;
			parameters[15].Value = model.LEAVEDATE;
			parameters[16].Value = model.BANKACCOUNT;
			parameters[17].Value = model.ADDRESS;
			parameters[18].Value = model.EMAIL;
			parameters[19].Value = model.NOTE;
			parameters[20].Value = model.ISCREDITMANAGE;
			parameters[21].Value = model.CREDITPERIOD;
			parameters[22].Value = model.CREDITLEVEL;
			parameters[23].Value = model.PROFESSIONALGROUP;
			parameters[24].Value = model.UUID;
			parameters[25].Value = model.BARCODES;
			parameters[26].Value = model.FOTHERARACCTID;
			parameters[27].Value = model.FOTHERAPACCTID;
			parameters[28].Value = model.FPREAPACCTID;
			parameters[29].Value = model.FPREARACCTID;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from EMPLOYEE ");
			strSql.Append(" where ");
			OracleParameter[] parameters = {
			};

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public TKFA.Model.EMPLOYEE GetModel()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select USERID,SNUMBER,NAME,PARENT,SLEVEL,ISDETAIL,EMPGROUP,SDEPARTMENTCODE,GENDER,BIRTHDAY,DEGREE,PHONE,CARDID,DUTY,HIREDATE,LEAVEDATE,BANKACCOUNT,ADDRESS,EMAIL,NOTE,ISCREDITMANAGE,CREDITPERIOD,CREDITLEVEL,PROFESSIONALGROUP,UUID,BARCODES,FOTHERARACCTID,FOTHERAPACCTID,FPREAPACCTID,FPREARACCTID from EMPLOYEE ");
			strSql.Append(" where ");
			OracleParameter[] parameters = {
			};

			TKFA.Model.EMPLOYEE model=new TKFA.Model.EMPLOYEE();
			DataSet ds=DbHelperOra.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public TKFA.Model.EMPLOYEE DataRowToModel(DataRow row)
		{
			TKFA.Model.EMPLOYEE model=new TKFA.Model.EMPLOYEE();
			if (row != null)
			{
				if(row["USERID"]!=null)
				{
					model.USERID=row["USERID"].ToString();
				}
				if(row["SNUMBER"]!=null)
				{
					model.SNUMBER=row["SNUMBER"].ToString();
				}
				if(row["NAME"]!=null)
				{
					model.NAME=row["NAME"].ToString();
				}
				if(row["PARENT"]!=null)
				{
					model.PARENT=row["PARENT"].ToString();
				}
				if(row["SLEVEL"]!=null)
				{
					model.SLEVEL=row["SLEVEL"].ToString();
				}
				if(row["ISDETAIL"]!=null)
				{
					model.ISDETAIL=row["ISDETAIL"].ToString();
				}
				if(row["EMPGROUP"]!=null)
				{
					model.EMPGROUP=row["EMPGROUP"].ToString();
				}
				if(row["SDEPARTMENTCODE"]!=null)
				{
					model.SDEPARTMENTCODE=row["SDEPARTMENTCODE"].ToString();
				}
				if(row["GENDER"]!=null)
				{
					model.GENDER=row["GENDER"].ToString();
				}
				if(row["BIRTHDAY"]!=null && row["BIRTHDAY"].ToString()!="")
				{
					model.BIRTHDAY=DateTime.Parse(row["BIRTHDAY"].ToString());
				}
				if(row["DEGREE"]!=null)
				{
					model.DEGREE=row["DEGREE"].ToString();
				}
				if(row["PHONE"]!=null)
				{
					model.PHONE=row["PHONE"].ToString();
				}
				if(row["CARDID"]!=null)
				{
					model.CARDID=row["CARDID"].ToString();
				}
				if(row["DUTY"]!=null)
				{
					model.DUTY=row["DUTY"].ToString();
				}
				if(row["HIREDATE"]!=null)
				{
					model.HIREDATE=row["HIREDATE"].ToString();
				}
				if(row["LEAVEDATE"]!=null)
				{
					model.LEAVEDATE=row["LEAVEDATE"].ToString();
				}
				if(row["BANKACCOUNT"]!=null)
				{
					model.BANKACCOUNT=row["BANKACCOUNT"].ToString();
				}
				if(row["ADDRESS"]!=null)
				{
					model.ADDRESS=row["ADDRESS"].ToString();
				}
				if(row["EMAIL"]!=null)
				{
					model.EMAIL=row["EMAIL"].ToString();
				}
				if(row["NOTE"]!=null)
				{
					model.NOTE=row["NOTE"].ToString();
				}
				if(row["ISCREDITMANAGE"]!=null)
				{
					model.ISCREDITMANAGE=row["ISCREDITMANAGE"].ToString();
				}
				if(row["CREDITPERIOD"]!=null)
				{
					model.CREDITPERIOD=row["CREDITPERIOD"].ToString();
				}
				if(row["CREDITLEVEL"]!=null)
				{
					model.CREDITLEVEL=row["CREDITLEVEL"].ToString();
				}
				if(row["PROFESSIONALGROUP"]!=null)
				{
					model.PROFESSIONALGROUP=row["PROFESSIONALGROUP"].ToString();
				}
				if(row["UUID"]!=null)
				{
					model.UUID=row["UUID"].ToString();
				}
				if(row["BARCODES"]!=null)
				{
					model.BARCODES=row["BARCODES"].ToString();
				}
				if(row["FOTHERARACCTID"]!=null)
				{
					model.FOTHERARACCTID=row["FOTHERARACCTID"].ToString();
				}
				if(row["FOTHERAPACCTID"]!=null)
				{
					model.FOTHERAPACCTID=row["FOTHERAPACCTID"].ToString();
				}
				if(row["FPREAPACCTID"]!=null)
				{
					model.FPREAPACCTID=row["FPREAPACCTID"].ToString();
				}
				if(row["FPREARACCTID"]!=null)
				{
					model.FPREARACCTID=row["FPREARACCTID"].ToString();
				}
			}
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select USERID,SNUMBER,NAME,PARENT,SLEVEL,ISDETAIL,EMPGROUP,SDEPARTMENTCODE,GENDER,BIRTHDAY,DEGREE,PHONE,CARDID,DUTY,HIREDATE,LEAVEDATE,BANKACCOUNT,ADDRESS,EMAIL,NOTE,ISCREDITMANAGE,CREDITPERIOD,CREDITLEVEL,PROFESSIONALGROUP,UUID,BARCODES,FOTHERARACCTID,FOTHERAPACCTID,FPREAPACCTID,FPREARACCTID ");
			strSql.Append(" FROM EMPLOYEE ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperOra.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM EMPLOYEE ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T.SALTERATIONCODE desc");
			}
			strSql.Append(")AS Row, T.*  from EMPLOYEE T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperOra.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			OracleParameter[] parameters = {
					new OracleParameter(":tblName", OracleType.VarChar, 255),
					new OracleParameter(":fldName", OracleType.VarChar, 255),
					new OracleParameter(":PageSize", OracleType.Number),
					new OracleParameter(":PageIndex", OracleType.Number),
					new OracleParameter(":IsReCount", OracleType.Clob),
					new OracleParameter(":OrderType", OracleType.Clob),
					new OracleParameter(":strWhere", OracleType.VarChar,1000),
					};
			parameters[0].Value = "EMPLOYEE";
			parameters[1].Value = "SALTERATIONCODE";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperOra.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  BasicMethod
		#region  ExtensionMethod

		#endregion  ExtensionMethod
	}
}

